﻿using System.Drawing;

namespace IceDog.DNF.Program.UnitTest.Helpers
{
    /// <summary>
    /// .Net Port Of Interop 帮助类
    /// </summary>
    public static class NPOIHelper
    {
        /// <summary>
        /// 获取缩进值
        /// </summary>
        /// <param name="indentCount">缩进数量</param>
        /// <param name="fontName">字体类型</param>
        /// <param name="fontSize">字体大小（单位是像素,px）</param>
        /// <param name="fontStyle">字体样式</param>
        /// <returns></returns>
        public static int GetIndentation(int indentCount, string fontName, int fontSize, FontStyle fontStyle)
        {
            Bitmap bmp = new Bitmap(500, 500);
            Graphics gp = Graphics.FromImage(bmp);
            gp.PageUnit = GraphicsUnit.Pixel;
            SizeF size = gp.MeasureString("字", new Font(fontName, fontSize, fontStyle, GraphicsUnit.Pixel));
            return (int)size.Width * indentCount * 10;
        }
    }
}
